import os
import sys

# 定义文件夹路径和要删除的特定字符串
folder_path = '.'
# string_to_remove = r' 沃尔夫冈·阿玛德乌斯·莫扎特 '
string_to_remove = sys.argv[1]

# 遍历文件夹中的所有文件
for filename in os.listdir(folder_path):
    # 检查文件是否包含要删除的字符串
    if string_to_remove in filename:
        # 构造完整的文件路径
        old_file_path = os.path.join(folder_path, filename)
        # 删除文件名中的特定字符串
        new_filename = filename.replace(string_to_remove, '')
        # 构造新的文件路径
        new_file_path = os.path.join(folder_path, new_filename)
        # 重命名文件
        os.rename(old_file_path, new_file_path)
        print(f'Renamed "{old_file_path}" to "{new_file_path}"')